//
//  ClubViewController.m
//  PaiQuan
//
//  Created by Mac on 16/7/7.
//  Copyright © 2016年 huigu. All rights reserved.
//

#import "ClubViewController.h"

#import "collateClubViewController.h"
#import "ClubConversationController.h"
@interface ClubViewController ()

@end

@implementation ClubViewController

- (void)viewDidLoad {
    [super viewDidLoad];
       //设置需要显示哪些类型的会话
    self.conversationListTableView.backgroundColor = PQ_COLOR_DarkGray;
    [self.emptyConversationView removeFromSuperview];
    [self setDisplayConversationTypes:@[@(ConversationType_PRIVATE),
                                         @(ConversationType_DISCUSSION),
                                         @(ConversationType_CHATROOM),
                                         @(ConversationType_GROUP),
                                         @(ConversationType_APPSERVICE),
                                         @(ConversationType_SYSTEM)]];
     //设置需要将哪些类型的会话在会话列表中聚合显示
     [self setCollectionConversationType:@[@(ConversationType_DISCUSSION),
                                           @(ConversationType_GROUP)]];}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    
}
- (void)onSelectedTableRow:(RCConversationModelType)conversationModelType
         conversationModel:(RCConversationModel *)model

               atIndexPath:(NSIndexPath *)indexPath {
    
    
    ClubConversationController *conversationVC = [[ClubConversationController alloc]init];
    conversationVC.conversationType = model.conversationType;
    conversationVC.targetId = model.targetId;
    conversationVC.title = @"俱乐部名字";
    
    
   
    [super.navigationController setNavigationBarHidden:NO];
   
    [self.navigationController pushViewController:conversationVC animated:YES];
}

-(CGFloat)rcConversationListTableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    return RATIO(138);
}
-(UIColor *)cellBackgroundColor{
    return PQ_COLOR_DarkGray;
}
-(void)willDisplayConversationTableCell:(RCConversationBaseCell *)cell atIndexPath:(NSIndexPath *)indexPath
{
    RCConversationModel *model= self.conversationListDataSource[indexPath.row];
    if (model.conversationType == ConversationType_PRIVATE) {
        RCConversationCell *concell = (RCConversationCell *)cell;
        //标题
        concell.messageCreatedTimeLabel.translatesAutoresizingMaskIntoConstraints = YES;
        [concell.messageCreatedTimeLabel makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(concell.top).offset(RATIO(5));
            make.right.equalTo(concell.right).offset(-RATIO(20));
            
        }];
        
        
        [concell.conversationTitle setTextColor:[UIColor whiteColor]];
        [concell.conversationTitle setFont:FONT(32)];
        [concell.messageContentLabel setTextColor:PQ_COLOR_SimpleGary];
        [concell.messageContentLabel setFont:FONT(RATIO(28))];
        //内容
        
        
        //button
        UIButton *rightBtn = [[UIButton alloc] init];
        rightBtn.backgroundColor = [UIColor yellowColor];
        [concell addSubview:rightBtn];
        [rightBtn setTitle:[NSString stringWithFormat:@"对局：%d",8] forState:UIControlStateNormal];
        [rightBtn.titleLabel setFont:FONT(13)];
        rightBtn.titleLabel.textAlignment = NSTextAlignmentCenter;
        rightBtn.backgroundColor = PQ_COLOR_YELLOW;
        [rightBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        rightBtn.layer.cornerRadius = 12;
        rightBtn.layer.masksToBounds = YES;
       
       
        [rightBtn makeConstraints:^(MASConstraintMaker *make) {
            make.width.equalTo(RATIO(112));
            make.height.equalTo(RATIO(50));
            make.right.equalTo(concell.right).offset(-RATIO(20));
            make.bottom.equalTo(concell.bottom).offset(-RATIO(20));
        }];
        [rightBtn addTarget:self action:@selector(cellRightBtnDidClick) forControlEvents:UIControlEventTouchUpInside];
       
        //headerView
        
        
        
        
        
        
        
        
    }
    
    
}

#pragma mark --按钮的点击事件
-(void)cellRightBtnDidClick{
    NSLog(@"点了");
    collateClubViewController *collcateVC = [[collateClubViewController alloc] init];
    [self.navigationController pushViewController:collcateVC animated:YES];
    
}
//-(void)tableView:(UITableView *)tableView willDisplayFooterView:(UIView *)view forSection:(NSInteger)section{
//    UILabel *footerlabel = [[UILabel alloc] init];
//    footerlabel.backgroundColor = PQ_COLOR_SimpleGary;
//    
//    [view addSubview:footerlabel];
//    [footerlabel setText:[NSString stringWithFormat:@"%d个俱乐部",4]];
//    [footerlabel setFont:FONT(13)];
//    footerlabel.textAlignment = NSTextAlignmentCenter;
//    
//    [footerlabel setTextColor:[UIColor whiteColor]];
//  
//    
//    [footerlabel makeConstraints:^(MASConstraintMaker *make) {
//        make.top.equalTo(view.top).offset(RATIO(44));
//        make.centerX.equalTo(view.centerX);
//            }];
//
//    
//}


/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
